﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using ExtAspNet;
namespace FTchina.Logic
{

    /// <summary>
    ///AlertLogin 的摘要说明
    /// </summary>
    public class AlertLogic
    {
        public AlertLogic()
        {
            //
            //TODO: 在此处添加构造函数逻辑
            //
        }
        /// <summary>
        /// 提示信息后跳转
        /// </summary>
        /// <param name="Message">信息</param>
        /// <param name="Title">标题</param>
        /// <param name="Url">跳转地址</param>
        /// <param name="IsTopFrame">true:父窗口跳转，false:当前窗口跳转</param>
        public static void ShowResultAndRedirect(string Message,string Title,  string Url,bool IsTopFrame)
        {
            ShowResultAndRedirect(Message, Title, MessageBoxIcon.Information, Url, IsTopFrame);
            
        }
        /// <summary>
        /// 提示信息后跳转
        /// </summary>
        /// <param name="Message">信息</param>
        /// <param name="Title">标题</param>
        ///<param name="icon">提示图标</param>
        /// <param name="Url">跳转地址</param>
        /// <param name="IsTopFrame">true:父窗口跳转，false:当前窗口跳转</param>
       
        public static void ShowResultAndRedirect(string Message, string Title, MessageBoxIcon icon, string Url, bool IsTopFrame)
        {
            string TargetFormat = "{0}window.location.href='{1}'";
            string Target = string.Empty;
            if (IsTopFrame)
            {
                Target = string.Format(TargetFormat, "parent.", Url);
            }
            else
            {
                Target = string.Format(TargetFormat, "", Url);
            }
            Alert.ShowInTop(Message, Title, icon, Target);
        }


        /// <summary>
        /// 提示操作结果
        /// </summary>
        /// <param name="flag"></param>
        public static void ShowResult(bool flag)
        {
            if (flag)
            {
                Alert.ShowInTop("操作成功！", "恭喜！", MessageBoxIcon.Information);
            }
            else
            {
                Alert.ShowInTop("操作失败！", "注意！", MessageBoxIcon.Error);
            }
        }

        public static void ShowError(string Message)
        {
            Alert.ShowInTop(Message, "注意！", MessageBoxIcon.Error);
        }
    }
}